package com.sctvcloud.renhe.ui.adapter;


import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.sctvcloud.renhe.beans.LiveItem;
import com.sctvcloud.renhe.beans.NewsItem;
import com.sctvcloud.renhe.ui.fragment.PlaceholderFragment;
import com.sctvcloud.renhe.ui.widget.BarragePlayerView;
import com.sctvcloud.renhe.ui.widget.BasePlayerView;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class DummyAdapter extends FragmentPagerAdapter {

    private List<NewsItem> newsList;
    private List<PlaceholderFragment> fragments;

    public DummyAdapter(FragmentManager fm, Context ctx) {
        super(fm);
        fragments = new ArrayList<>();
//        videoPlayer = new BasePlayerView(ctx);
    }

    @Override
    public Fragment getItem(int position) {
        if (fragments.size() > position) {
            return fragments.get(position);
        } else {
            PlaceholderFragment f = new PlaceholderFragment();
            fragments.add(f);
            return f;
        }
        // getItem is called to instantiate the fragment for the given page.
        // Return a PlaceholderFragment (defined as a static inner class below).
//        videoPlayer.
//        return PlaceholderFragment.newInstance(position + 1);
    }

    @Override
    public int getCount() {
        // Show 3 total pages.
        if (null != newsList) {
            return newsList.size();
        } else {
            return 0;
        }
    }


    public void setDataList(List<NewsItem> liveList) {
        this.newsList = liveList;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        Locale l = Locale.getDefault();
        switch (position) {
            case 0:
                return "PAGE 1";
            case 1:
                return "PAGE 2";
            case 2:
                return "PAGE 3";
        }
        return null;
    }

}